/* 歌单api */
import request from "@/utils/request"
import store from "@/store"
let cookie = store.state.usercookie
/* 
获取歌单信息
 */
export const getplaylistAPI = (id) => {
  return request({
    method: "GET",
    url: "/playlist/detail",
    params: {
      id,
      cookie,
    },
  })
}
/* 
获取歌单详细歌曲信息
注：关于offset，你可以这样理解，假设你当前的歌单有100首歌

你传入limit=10&offset=0等价于limit=10，你会得到第1-10首歌曲

你传入limit=10&offset=1，你会得到第2-11首歌曲

如果你设置limit=10&offset=2，你就会得到第3-12首歌曲
 */
export const getplaylisttrackAPI = (id, limit, offset) => {
  return request({
    method: "GET",
    url: "/playlist/track/all",
    params: {
      id,
      limit,
      offset,
      cookie,
    },
  })
}

/* 
获取相关歌单
 */
export const getrelatedplaylistAPI = (id) => {
  return request({
    method: "GET",
    url: "/related/playlist",
    params: {
      id,
      cookie,
    },
  })
}
/* 
获取歌单评论
 */
export const getcommentplaylistAPI = (id, limit, offset, before) => {
  return request({
    method: "GET",
    url: "/comment/playlist",
    params: {
      id,
      limit,
      offset,
      before,
      cookie,
    },
  })
}

/* 
获取歌单收藏者
 */
export const getplaylistsubAPI = (id, limit, offset) => {
  return request({
    method: "GET",
    url: "/playlist/subscribers",
    params: {
      id,
      limit,
      offset,
      cookie,
    },
  })
}
/* 
获取歌单分类
 */
export const getplaylistcatlistAPI = () => {
  return request({
    method: "GET",
    url: "/playlist/catlist",
   params:{
    cookie,
   }
  })
}
/* 
获取热门歌单
 */
export const gethotplaylistAPI = () => {
  return request({
    method: "GET",
    url: "/playlist/hot",
    params:{
      cookie,
     }
  })
}
/* 
获取精品歌单
可选参数 : cat: tag, 比如 " 华语 "、" 古风 " 、" 欧美 "、" 流行 ", 默认为 "全部",可从精品歌单标签列表接口获取(/playlist/highquality/tags)
limit: 取出歌单数量 , 默认为 50
before: 分页参数,取上一页最后一个歌单的 updateTime 获取下一页数据
 */
export const gethighqualityplaylistAPI = (cat,limit,before) => {
  return request({
    method: "GET",
    url: "/top/playlist/highquality",
    params:{
      cookie,cat,limit,before
     }
  })
}
/* 
获取网友精品歌单
 */
export const gettopplaylistAPI = (cat,limit,offset) => {
  return request({
    method: "GET",
    url: "/top/playlist",
    params:{
      cookie,
      cat,limit,offset
     }
  })
}
/*
获取精品歌单标签
 */
export const gethighqualityplaylistagstAPI = () => {
  return request({
    method: "GET",
    url: "/playlist/highquality/tags",
    params:{
      cookie,
     }
  })
}
